package com.tensquare.user;

import com.tensquare.user.interceptor.JwtInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * Created with IDEA
 * author:zhiXiang-Chen
 * Date:2019/3/6
 * Time:10:35
 */
@Component
public class ApplicationConfig extends WebMvcConfigurationSupport {


    @Autowired
    private JwtInterceptor jwtInterceptor;

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        //这个配置作用是  拦截哪些请求 addPathPatterns拦截所有  excludePathPatterns 这些不拦截 一般登录注册不拦截
        //是否放行  是JwtInterceptor这个类的返回值决定的  true放行 反之
        registry.addInterceptor(jwtInterceptor).addPathPatterns("/**").excludePathPatterns("/**/login");
    }
}
